namespace FIREFLYX {
    /**
     * webgl 纹理激活器
     */
    export class TextureActivator {
        private _currUse: number;
        private _currActID: number;
        private _gl: WebGL2RenderingContext;
        /** 当前设备最大纹理数 */
        private _maxCount: number;
        constructor(gl: WebGL2RenderingContext) {
            this._gl = gl;
            this._currUse = 0;
            this._currActID = 0;
            this._maxCount = WebglCapability.MAX_COMBINED_TEXTURE_IMAGE_UNITS;
        }
        /** 当前设备支持的shader纹理数最大数量 */
        public get maxCount() { return this._maxCount; }
        /** 当前激活的纹理槽位ID */
        public get currActiveTexID() { return this._currActID; }
        /** 激活一个纹理槽位 */
        public activeTexOnce(): boolean {
            const gl = this._gl;
            const texID = this._currUse;
            if (texID >= this._maxCount) return false;
            this._currActID = texID;
            gl.activeTexture((gl as any)[`TEXTURE${texID}`]);
            this._currUse++;
            return true;
        }
        /** 重置 */
        public reset() { this._currUse = 0; }
    }
}